﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PDFHelper.Helper;

namespace ITextSharpSample
{
    public partial class PDFToSwf : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                iframeViewSwf.Visible = false;

            }
        }

        protected void btnGen_Click(object sender, EventArgs e)
        {
            if (this.fuFile.HasFile)
            {
                if (fuFile.FileName.ToLower().EndsWith(".pdf"))
                {
                    string fileName = Guid.NewGuid().ToString();
                    fuFile.SaveAs(Server.MapPath("~/Pdf/" + fileName + ".pdf"));
                    if (TextSharpHelper.PDF2Swf(this.Pdf2Swf, Server.MapPath("~/Pdf/" + fileName + ".pdf"), Server.MapPath("~/swf/" + fileName + ".swf")))
                    {
                        iframeViewSwf.Attributes.Add("src", string.Format("PdfView.aspx?file=" + fileName));
                        iframeViewSwf.Visible = true;
                        return;
                    }
                }
            }

            iframeViewSwf.Visible = false;
        }
    }
}